#include "ImplementationIW.h"


#include <QWidget>
#include "Operation.h"
#include <QApplication>

/**
  * Generic for Window
  */

IWImplementation::IWImplementation(QString str) : GenericOperation(str.toStdString())
{
    //void
}

iwZoomPlusOp::iwZoomPlusOp() : IWImplementation(qApp->translate("Operations", "Zoom plus"))
{
    initShortcut(new QKeySequence(qApp->translate("","Ctrl++")));
}

void iwZoomPlusOp::operator()(const genericinterface::ImageWindow* currentWnd, const std::vector<const genericinterface::ImageWindow*>&){
    (const_cast<ImageWindow *>(currentWnd))->zoom(1);
}

iwZoomMoinsOp::iwZoomMoinsOp() : IWImplementation(qApp->translate("Operations", "Zoom minus"))
{
    initShortcut(new QKeySequence(qApp->translate("","Ctrl+-")));
}

void iwZoomMoinsOp::operator()(const genericinterface::ImageWindow* currentWnd, const std::vector<const genericinterface::ImageWindow*>&){
    (const_cast<ImageWindow *>(currentWnd))->zoom(-1);
}

iwApplyMaskOp::iwApplyMaskOp() : IWImplementation(qApp->translate("Operations", "Apply Mask"))
{
    //void
}

void iwApplyMaskOp::operator()(const genericinterface::ImageWindow* currentWnd, const std::vector<const genericinterface::ImageWindow*>&){
    (const_cast<ImageWindow *>(currentWnd))->applyBinaryMask();
}


iwRenameOp::iwRenameOp() : IWImplementation(qApp->translate("Operations", "Rename"))
{
    initShortcut(new QKeySequence(Qt::Key_F2));
}

void iwRenameOp::operator()(const genericinterface::ImageWindow* currentWnd, const std::vector<const genericinterface::ImageWindow*>& wndList){
    genericinterface::ImageWindow * iw = const_cast<genericinterface::ImageWindow*>(currentWnd);
    iw->rename();
}

iwPixelGridOp::iwPixelGridOp(): IWImplementation(qApp->translate("Operations", "Pixel grid"))
{
    initShortcut(new QKeySequence(qApp->translate("","Ctrl+G")));
}

void iwPixelGridOp::operator()(const genericinterface::ImageWindow* currentWnd, const std::vector<const genericinterface::ImageWindow*>&){
    if(currentWnd->isStandard()){
        (dynamic_cast<StandardImageWindow *>(const_cast<ImageWindow *>(currentWnd)))->showPixelsGrid();
    }else if(currentWnd->isDouble()){
        (dynamic_cast<DoubleImageWindow *>(const_cast<ImageWindow *>(currentWnd)))->showPixelsGrid();
    }
}


iwCropOp::iwCropOp(): IWImplementation(qApp->translate("Operations", "Crop"))
{
    //void
}

void iwCropOp::operator()(const genericinterface::ImageWindow* currentWnd, const std::vector<const genericinterface::ImageWindow*>&){
    if(currentWnd->isStandard()){
        (dynamic_cast<StandardImageWindow *>(const_cast<ImageWindow *>(currentWnd)))->crop();
    }else if(currentWnd->isDouble()){
        (dynamic_cast<DoubleImageWindow *>(const_cast<ImageWindow *>(currentWnd)))->crop();
    }
}

iwCopyCropOp::iwCopyCropOp(): IWImplementation(qApp->translate("Operations", "Copy crop"))
{
    //void
}

void iwCopyCropOp::operator()(const genericinterface::ImageWindow* currentWnd, const std::vector<const genericinterface::ImageWindow*>&){
    if(currentWnd->isStandard()){
        (dynamic_cast<StandardImageWindow *>(const_cast<ImageWindow *>(currentWnd)))->copycrop();
    }else if(currentWnd->isDouble()){
        (dynamic_cast<DoubleImageWindow *>(const_cast<ImageWindow *>(currentWnd)))->copycrop();
    }
}

/**
  * Specific for standard Window
  */
SIWImplementation::SIWImplementation(QString str) : GenericOperation(str.toStdString())
{
    //void
}

siwHistogramOp::siwHistogramOp(): SIWImplementation(qApp->translate("Operations", "Histogram"))
{
    //void
}

void siwHistogramOp::operator()(const genericinterface::ImageWindow* currentWnd, const std::vector<const genericinterface::ImageWindow*>&){
    (dynamic_cast<StandardImageWindow *>(const_cast<ImageWindow *>(currentWnd)))->showHistogram();
}

siwCumulatedHistogramOp::siwCumulatedHistogramOp(): SIWImplementation(qApp->translate("Operations", "Cumulated Histogram"))
{
    //void
}

void siwCumulatedHistogramOp::operator()(const genericinterface::ImageWindow* currentWnd, const std::vector<const genericinterface::ImageWindow*>&){
    (dynamic_cast<StandardImageWindow *>(const_cast<ImageWindow *>(currentWnd)))->showCumulatedHistogram();
}

siwHProjectionHistogram::siwHProjectionHistogram(): SIWImplementation(qApp->translate("Operations", "Horizontal Projection Histogram"))
{
    //void
}

void siwHProjectionHistogram::operator()(const genericinterface::ImageWindow* currentWnd, const std::vector<const genericinterface::ImageWindow*>&){
    (dynamic_cast<StandardImageWindow *>(const_cast<ImageWindow *>(currentWnd)))->showHProjectionHistogram();
}

siwLineProfile::siwLineProfile(): SIWImplementation(qApp->translate("Operations", "Line Profile"))
{
    //void
}

void siwLineProfile::operator()(const genericinterface::ImageWindow* currentWnd, const std::vector<const genericinterface::ImageWindow*>&){
    (dynamic_cast<StandardImageWindow *>(const_cast<ImageWindow *>(currentWnd)))->showLineProfile();
}

siwColumnProfile::siwColumnProfile(): SIWImplementation(qApp->translate("Operations", "Colum Profile"))
{
    //void
}

void siwColumnProfile::operator()(const genericinterface::ImageWindow* currentWnd, const std::vector<const genericinterface::ImageWindow*>&){
    (dynamic_cast<StandardImageWindow *>(const_cast<ImageWindow *>(currentWnd)))->showColumnProfile();
}

siwconvertToGrayscale::siwconvertToGrayscale(): SIWImplementation(qApp->translate("Operations", "Convert to Grayscale"))
{
    //void
}

void siwconvertToGrayscale::operator()(const genericinterface::ImageWindow* currentWnd, const std::vector<const genericinterface::ImageWindow*>&){
    (dynamic_cast<StandardImageWindow *>(const_cast<ImageWindow *>(currentWnd)))->convertToGrayscale();
}

siwconvertToBinary::siwconvertToBinary(): SIWImplementation(qApp->translate("Operations", "Convert to binary"))
{
    //void
}

void siwconvertToBinary::operator()(const genericinterface::ImageWindow* currentWnd, const std::vector<const genericinterface::ImageWindow*>&){
    (dynamic_cast<StandardImageWindow *>(const_cast<ImageWindow *>(currentWnd)))->convertToBinary();;
}

/**
  * Specific for standard Window
  */
DIWImplementation::DIWImplementation(QString str) : GenericOperation(str.toStdString())
{
    //void
}
/*
 *There is no implementation nowadays
 */



